from redis import ConnectionPool, StrictRedis


class RedisClient(object):
    pool = ConnectionPool(**{
        'host': '39.105.230.139',
        'port': 6379,
        'db': 0,
        'password': 950218
    })
    client = StrictRedis(connection_pool=pool)

    def SetCookies(self, cookies):
        self.client.set('pp_cookies', cookies)

    def GetCookies(self):
        return str(self.client.get('pp_cookies'), encoding='utf-8')

    def GetPaper(self):
        paper = self.client.lpop('paper')
        if paper:
            return str(paper, encoding='utf-8')
        else:
            return None


if __name__ == '__main__':
    r = RedisClient()
    print(r.GetCookies())
